*********************************************************************************
*** Figure 4
*********************************************************************************

* Project: 	International threats and European defense
* Authors: 	Matthias Mader
* Date:		March 2023	

* Data: VW Project, Pane-European survey (W1)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind, permanent				// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Times New Roman"		// set font in graphs | "Arial" | "Times New Roman"


***Figure 4
	
	use DATA_clean, clear

	*Austria for labels (first, top-left panel)
	reg csdp_wouldlike c.threat_ind2##i.idconfig2##i.QCOUNTRY female age education iso comp mili
	foreach val in 1 {
	local v : label (QCOUNTRY) `val'
	margins, at(threat_ind2=(0 (.025) 1) idconfig=(1 2) QCOUNTRY=(`val'))
	marginsplot,  ///
		name(c`val', replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		text(.90 -0.01 "Inclusive identity", color(gs9) place(right) size(large)) ///
		text(0.45 -0.01  "Exclusive national identity", color(gs0) place(right) size(large)) ///
		ciopts(recast(rbar) barwidth(0.01)) ci1opts(color(gs0) alcolor(none)) ci2opts(color(gs9%80) alcolor(none)) ///
		ylab(, nogrid) ///
		xlab(, nogrid) ///
		graphregion(margin(l=-6 r=-5 t=-4 b=-4)) ///
		xtitle("") xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("") yscale(range(.2 1)) ylabel(.2 (0.2) 1, labsize(large)) ///	
		title("") ///
		text(.3 1 "`v'", size(vlarge) place(left)) ///
		legend(off)
}


	*All other countries ("top-right" quadrant)
	reg csdp_wouldlike c.threat_ind2##i.idconfig2##i.QCOUNTRY female age education iso comp mili
	foreach val in 2 3 4 5 7 8 9 10 12 13 14 15 17 18 19 20 {
	local v : label (QCOUNTRY) `val'
	margins, at(threat_ind2=(0 (.025) 1) idconfig=(1 2) QCOUNTRY=(`val'))
	marginsplot,  ///
		name(c`val', replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		ciopts(recast(rbar) barwidth(0.01)) ci1opts(color(gs0) alcolor(none)) ci2opts(color(gs9%80) alcolor(none)) ///
		ylab(, nogrid labcolor(white)) ///
		xlab(, nogrid labcolor(white)) ///
		graphregion(margin(l=-6 r=-5 t=-4 b=-4)) ///
		xtitle("") xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("") yscale(range(.2 1)) ylabel(.2 (0.2) 1, labsize(large)) ///	
		title("") ///
		text(.3 1 "`v'", size(vlarge) place(left)) ///
		legend(off)
}

	*All other countries (first column)
	reg csdp_wouldlike c.threat_ind2##i.idconfig2##i.QCOUNTRY female age education iso comp mili
	foreach val in 6 11 16 {
	local v : label (QCOUNTRY) `val'
	margins, at(threat_ind2=(0 (.025) 1) idconfig=(1 2) QCOUNTRY=(`val'))
	marginsplot,  ///
		name(c`val', replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		ciopts(recast(rbar) barwidth(0.01)) ci1opts(color(gs0) alcolor(none)) ci2opts(color(gs9%80) alcolor(none)) ///
		ylab(, nogrid) ///
		xlab(, nogrid labcolor(white)) ///
		graphregion(margin(l=-6 r=-5 t=-4 b=-4)) ///
		xtitle("") xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("") yscale(range(.2 1)) ylabel(.2 (0.2) 1, labsize(large)) ///	
		title("") ///
		text(.3 1 "`v'", size(vlarge) place(left)) ///
		legend(off)
}

	*All other countries (first column, last row)
	reg csdp_wouldlike c.threat_ind2##i.idconfig2##i.QCOUNTRY female age education iso comp mili
	foreach val in 21 {
	local v : label (QCOUNTRY) `val'
	margins, at(threat_ind2=(0 (.025) 1) idconfig=(1 2) QCOUNTRY=(`val'))
	marginsplot,  ///
		name(c`val', replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		ciopts(recast(rbar) barwidth(0.01)) ci1opts(color(gs0) alcolor(none)) ci2opts(color(gs9%80) alcolor(none)) ///
		ylab(, nogrid) ///
		xlab(, nogrid) ///
		graphregion(margin(l=-6 r=-5 t=-4 b=-4)) ///
		xtitle("") xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("") yscale(range(.2 1)) ylabel(.2 (0.2) 1, labsize(large)) ///	
		title("") ///
		text(.3 1 "`v'", size(vlarge) place(left)) ///
		legend(off)
}

	*All other countries (last row)
	reg csdp_wouldlike c.threat_ind2##i.idconfig2##i.QCOUNTRY female age education iso comp mili
	foreach val in 22 23 24 25 {
	local v : label (QCOUNTRY) `val'
	margins, at(threat_ind2=(0 (.025) 1) idconfig=(1 2) QCOUNTRY=(`val'))
	marginsplot,  ///
		name(c`val', replace) ///
		recast(scatter) ///
		plot1opts(mcolor(none)) plot2opts(mcolor(none)) ///
		ciopts(recast(rbar) barwidth(0.01)) ci1opts(color(gs0) alcolor(none)) ci2opts(color(gs9%80) alcolor(none)) ///
		ylab(, nogrid labcolor(white)) ///
		xlab(, nogrid) ///
		graphregion(margin(l=-6 r=-5 t=-4 b=-4)) ///
		xtitle("") xscale(range(0 1)) xlabel(0 (0.2) 1, labsize(large)) ///	
		ytitle("") yscale(range(.2 1)) ylabel(.2 (0.2) 1, labsize(large)) ///	
		title("") ///
		text(.3 1 "`v'", size(vlarge) place(left)) ///
		legend(off)
}


graph combine c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25, l1("Support for security/defence integration", size(small)) b1(Threat perception, size(small)) xcommon ycommon

